<?php
namespace App\Models;

use Dcat\Admin\Models\Administrator;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\SoftDeletes;

class AdminUser extends Administrator
{
    use HasDateTimeFormatter, SoftDeletes;

    protected $fillable = ['username', 'password', 'sex', 'phone', 'email', 'name', 'avatar', 'gid', 'zjhm', 'is_enable', 'dwmc', 'dwdm', 'deleted_at', 'created_at', 'updated_at'];

    public static function findByGid($gid)
    {
        return self::query()->where('gid', $gid)->first();
    }

    public function isSuperManger()
    {
        return $this->inRoles([Role::ROLE_SLUG_SUPER_MANGER, Role::ROLE_SLUG_administrator]);
    }

    public static function findByDwdm($dwdm)
    {
        return self::query()->where('dwdm', $dwdm)->first();
    }

    public static function findByDdbDwdm($dwdm)
    {
        return self::query()->where('ddb_dwdm', $dwdm)->first();
    }

}
